package JavaApi;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.temporal.ChronoField;

public class Time {


    public static void main(String[] args) {
        LocalDate date = LocalDate.now();

        System.out.println(date.get(ChronoField.YEAR));//年
        System.out.println(date.get(ChronoField.MONTH_OF_YEAR));//月
        System.out.println(date.get(ChronoField.DAY_OF_MONTH));//日
        System.out.println(date.get(ChronoField.DAY_OF_WEEK));//周几
        System.out.println(date.get(ChronoField.DAY_OF_YEAR));//一天的第几天

        LocalTime time = LocalTime.now();
        System.out.println(time.get(ChronoField.HOUR_OF_DAY)); //时
        System.out.println(time.get(ChronoField.MINUTE_OF_HOUR));//分
        System.out.println(time.get(ChronoField.SECOND_OF_MINUTE));//秒

        LocalDateTime dateTime = LocalDateTime.now();
        System.out.println(dateTime.plusHours(10));


        System.out.println(Duration.between(LocalDateTime.now(), LocalDateTime.now()));

    }
}
